#include "mod_fontdlg.as"
#include "gdi32.as"

#define ctype RGB(%1,%2,%3) (%1 | %2 << 8 | %3 << 16)

/*ϐ̈ꗗ
str_x,str_ycXN[TCY(^ϐ)
x,ycXN[TCY(^ϐ)
b_x,b_ycωÕEBhETCY
f_x,f_ycEBhȄʒu(^ϐ)
int_f_x,int_f_ycEBhȄʒu(^ϐ)
memory_0 ` memory_9ctⳂ̓e
font_modectHg̎
font_sizectHg̃TCY(^ϐ)
font_stylectHgX^C(^ϐ)
font_color_R or G or BctHgJ[(^ϐ)
int_font_sizectHgTCY(^ϐ)
int_font_stylectHgX^C(^ϐ)
int_font_color_R or G or BctHgJ[(^ϐ)
back_color_R or G or BcwiF(^ϐ)
int_back_color_R or G or BcwiF(^ϐ)
main_key(0) ` main(9)cCL[{[h0`9
ctrlcCTRLL[
esccescL[
memory_noctⳂ̓e(^ϐ)
int_memory_noctⳂ̓e(^ϐ)
key_nocOÑL[
yearcN
monthc
dayofweekcj
dayc
hourc
minc
secondcb
mes_infcbZ[W{bNX̏
hBrushcwiFp̃uV
sooncꎞIɋL^̕ϐ
wincEBhE[h@2cANeBu@-1c\
*/

gsel 0,-1

dim main_key,10

exist "data\\memory_0.txt"

if(strsize = -1){
	notesel memory_0
	notesave "data\\memory_0.txt"

	notesel memory_1
	notesave "data\\memory_1.txt"

	notesel memory_2
	notesave "data\\memory_2.txt"

	notesel memory_3
	notesave "data\\memory_3.txt"

	notesel memory_4
	notesave "data\\memory_4.txt"

	notesel memory_5
	notesave "data\\memory_5.txt"

	notesel memory_6
	notesave "data\\memory_6.txt"

	notesel memory_7
	notesave "data\\memory_7.txt"

	notesel memory_8
	notesave "data\\memory_8.txt"

	notesel memory_9
	notesave "data\\memory_9.txt"
	
	notesel memory_no
	notesave "data\\memory_no.txt"
	
	notesel font_mode
	notesave "data\\font.txt"
	
	notesel font_size
	notesave "data\\font_size.txt"
	
	str_x = "350"
	str_y = "300"
	
	notesel str_x
	notesave "data\\x.txt"
	
	notesel str_y
	notesave "data\\y.txt"
	
	notesel f_x
	notesave "data\\f_x.txt"
	
	notesel f_y
	notesave "data\\f_y.txt"
}

exist "data\\font_color_R.txt"

if(strsize = -1){
	notesel font_style
	notesave "data\\font_style.txt"

	notesel font_color_R
	notesave "data\\font_color_R.txt"

	notesel font_color_G
	notesave "data\\font_color_G.txt"
	
	notesel font_color_B
	notesave "data\\font_color_B.txt"

	back_color_R = "255"
	back_color_G = "255"
	back_color_B = "255"

	notesel back_color_R
	notesave "data\\back_color_R.txt"

	notesel back_color_G
	notesave "data\\back_color_G.txt"

	notesel back_color_B
	notesave "data\\back_color_B.txt"
}

notesel str_x
noteload "data\\x.txt"

notesel str_y
noteload "data\\y.txt"

x = int(str_x)
y = int(str_y)

notesel f_x
noteload "data\\f_x.txt"

notesel f_y
noteload "data\\f_y.txt"

int_f_x = int(f_x)
int_f_y = int(f_y)

screen 1,ginfo_dispx,ginfo_dispy,0,int_f_x,int_f_y,x,y
gsel 1,2

win = 2

notesel memory_0
noteload "data\\memory_0.txt"

notesel memory_1
noteload "data\\memory_1.txt"

notesel memory_2
noteload "data\\memory_2.txt"

notesel memory_3
noteload "data\\memory_3.txt"

notesel memory_4
noteload "data\\memory_4.txt"

notesel memory_5
noteload "data\\memory_5.txt"

notesel memory_6
noteload "data\\memory_6.txt"

notesel memory_7
noteload "data\\memory_7.txt"

notesel memory_8
noteload "data\\memory_8.txt"

notesel memory_9
noteload "data\\memory_9.txt"

notesel memory_no
noteload "data\\memory_no.txt"

notesel font_mode
noteload "data\\font.txt"

notesel font_size
noteload "data\\font_size.txt"

notesel font_style
noteload "data\\font_style.txt"

notesel font_color_R
noteload "data\\font_color_R.txt"

notesel font_color_G
noteload "data\\font_color_G.txt"

notesel font_color_B
noteload "data\\font_color_B.txt"

notesel back_color_R
noteload "data\\back_color_R.txt"

notesel back_color_G
noteload "data\\back_color_G.txt"

notesel back_color_B
noteload "data\\back_color_B.txt"

int_font_size = int(font_size)
int_font_style = int(font_style)
int_memory_no = int(memory_no)

int_font_color_R = int(font_color_R)
int_font_color_G = int(font_color_G)
int_font_color_B = int(font_color_B)

int_back_color_R = int(back_color_R)
int_back_color_G = int(back_color_G)
int_back_color_B = int(back_color_B)

objmode 2,1

font font_mode,int_font_size,int_font_style

oncmd gosub *ctlcoloredit, $133

switch int_memory_no
case 0
	mesbox memory_0,x,y,1,0
	swbreak
	
case 1
	mesbox memory_1,x,y,1,0
	swbreak
	
case 2
	mesbox memory_2,x,y,1,0
	swbreak
	
case 3
	mesbox memory_3,x,y,1,0
	swbreak
	
case 4
	mesbox memory_4,x,y,1,0
	swbreak
	
case 5
	mesbox memory_5,x,y,1,0
	swbreak
	
case 6
	mesbox memory_6,x,y,1,0
	swbreak
	
case 7
	mesbox memory_7,x,y,1,0
	swbreak
	
case 8
	mesbox memory_8,x,y,1,0
	swbreak
	
case 9
	mesbox memory_9,x,y,1,0
	swbreak

swend

mes_inf = objinfo(stat, 2)

;wiJ[p̃uV𐶐nh擾B
CreateSolidBrush RGB(int_back_color_R, int_back_color_G, int_back_color_B)
hBrush = stat

*main
	onexit goto *final
	
	year = gettime(0)
	month = gettime(1)
	dayofweek = gettime(2)
	day = gettime(3)
	hour = gettime(4)
	min = gettime(5)
	second = gettime(6)
	
	if dayofweek = 0:str_dayofweek = ""
	if dayofweek = 1:str_dayofweek = ""
	if dayofweek = 2:str_dayofweek = ""
	if dayofweek = 3:str_dayofweek = ""
	if dayofweek = 4:str_dayofweek = ""
	if dayofweek = 5:str_dayofweek = ""
	if dayofweek = 6:str_dayofweek = "y"
	
	title "tver.1.25 "//+month+"/"+day+" "+hour+":"+min+":"+second+" ("+str_dayofweek+")"
	
	repeat 10
		getkey main_key(cnt),48 + cnt
	loop
	getkey ctrl,17
	getkey f1,112
	getkey f2,113
	stick key,0,0	;128
	
	if f1 = 1:gosub *font_set
	if f2 = 1:gosub *back_color_set
	if key = 128:if win = 2:gsel 1,-1:win = -1:else:gsel 1,2:win = 2:objsel 0
	
	if(ctrl = 1){
		repeat 10
			if main_key(cnt) = 1:key_no = cnt:gosub *change:break
		loop
	}
	
	if ginfo_sizex ! b_x | ginfo_sizey ! b_y:x = ginfo_sizex - 16:y = ginfo_sizey - 38:gosub *change
	
	b_x = ginfo_sizex
	b_y = ginfo_sizey
	
	await 1
goto *main

*ctlcoloredit
;	lparamɃIuWFNg̃EBhEnhԂ
	if mes_inf = lparam {
		SetTextColor wparam, RGB(int_font_color_R,int_font_color_G,int_font_color_B)

;		eLXgwiF (hBrush.0ƓFw)
		SetBkColor wparam, RGB(int_back_color_R,int_back_color_G,int_back_color_B)

;		{bNXwiF
		return hBrush
	}

	return

*change	
	pos 0,0
	
	switch int_memory_no
	
	case 0	
	notesel memory_0
	notesave "data\\memory_0.txt"
	swbreak

	case 1
	notesel memory_1
	notesave "data\\memory_1.txt"
	swbreak

	case 2
	notesel memory_2
	notesave "data\\memory_2.txt"
	swbreak

	case 3
	notesel memory_3
	notesave "data\\memory_3.txt"
	swbreak

	case 4
	notesel memory_4
	notesave "data\\memory_4.txt"
	swbreak

	case 5
	notesel memory_5
	notesave "data\\memory_5.txt"
	swbreak

	case 6
	notesel memory_6
	notesave "data\\memory_6.txt"
	swbreak

	case 7
	notesel memory_7
	notesave "data\\memory_7.txt"
	swbreak

	case 8
	notesel memory_8
	notesave "data\\memory_8.txt"
	swbreak

	case 9
	notesel memory_9
	notesave "data\\memory_9.txt"
	swbreak

	swend
	
	int_memory_no = key_no
	
	cls 0
	
	objmode 2,1
	font font_mode,int_font_size,int_font_style
	
	switch int_memory_no
	case 0
		mesbox memory_0,x,y,1,0
		swbreak
	
	case 1
		mesbox memory_1,x,y,1,0
		swbreak
	
	case 2
		mesbox memory_2,x,y,1,0
		swbreak
	
	case 3
		mesbox memory_3,x,y,1,0
		swbreak
	
	case 4
		mesbox memory_4,x,y,1,0
		swbreak
	
	case 5
		mesbox memory_5,x,y,1,0
		swbreak
	
	case 6
		mesbox memory_6,x,y,1,0
		swbreak
	
	case 7
		mesbox memory_7,x,y,1,0
		swbreak
	
	case 8
		mesbox memory_8,x,y,1,0
		swbreak
	
	case 9
		mesbox memory_9,x,y,1,0
		swbreak

	swend

	objsel 0

	mes_inf = objinfo(stat, 2)

	;wiJ[p̃uV𐶐nh擾B
	CreateSolidBrush RGB(int_back_color_R, int_back_color_G, int_back_color_B)
	hBrush = stat

	repeat -1
	getkey soon,int_memory_no + 48
	if soon = 0:break
	await 1
	loop

	return
	
*font_set
	fontdlg font_inf,0x100
	if(stat ! 0){
		font_mode = refstr
		int_font_size = font_inf(0)
		if font_inf(1) = 0:int_font_style = 0
		if font_inf(1) = 1:int_font_style = 1
		if font_inf(1) = 2:int_font_style = 2
		if font_inf(1) = 3:int_font_style = 3
		if font_inf(6) = 1:int_font_style + 4
		if font_inf(7) = 1:int_font_style + 8
		int_font_color_R = font_inf(3)
		int_font_color_G = font_inf(4)
		int_font_color_B = font_inf(5)
		gosub *change
	}
	
	objsel 0
	
	return

*back_color_set
	dialog "wiFZbgĂ",33
	if(stat ! 0){
		int_back_color_R = ginfo_r
		int_back_color_G = ginfo_g
		int_back_color_B = ginfo_b
		gosub *change
	}
	
	objsel 0
	
	return

*final
	switch int_memory_no
	
	case 0	
	notesel memory_0
	notesave "data\\memory_0.txt"
	swbreak

	case 1
	notesel memory_1
	notesave "data\\memory_1.txt"
	swbreak

	case 2
	notesel memory_2
	notesave "data\\memory_2.txt"
	swbreak

	case 3
	notesel memory_3
	notesave "data\\memory_3.txt"
	swbreak

	case 4
	notesel memory_4
	notesave "data\\memory_4.txt"
	swbreak

	case 5
	notesel memory_5
	notesave "data\\memory_5.txt"
	swbreak

	case 6
	notesel memory_6
	notesave "data\\memory_6.txt"
	swbreak

	case 7
	notesel memory_7
	notesave "data\\memory_7.txt"
	swbreak

	case 8
	notesel memory_8
	notesave "data\\memory_8.txt"
	swbreak

	case 9
	notesel memory_9
	notesave "data\\memory_9.txt"
	swbreak

	swend
	
	memory_no = str(int_memory_no)
	
	notesel memory_no
	notesave "data\\memory_no.txt"
	
	notesel font_mode
	notesave "data\\font.txt"
	
	font_size = str(int_font_size)
	
	notesel font_size
	notesave "data\\font_size.txt"
	
	str_x = str(x)
	str_y = str(y)
	
	notesel str_x
	notesave "data\\x.txt"
	
	notesel str_y
	notesave "data\\y.txt"
	
	f_x = str(ginfo_wx1)
	f_y = str(ginfo_wy1)
	
	notesel f_x
	notesave "data\\f_x.txt"
	
	notesel f_y
	notesave "data\\f_y.txt"
	
	font_color_R = str(int_font_color_R)
	font_color_G = str(int_font_color_G)
	font_color_B = str(int_font_color_B)

	back_color_R = str(int_back_color_R)
	back_color_G = str(int_back_color_G)
	back_color_B = str(int_back_color_B)
	
	notesel font_color_R
	notesave "data\\font_color_R.txt"

	notesel font_color_G
	notesave "data\\font_color_G.txt"
	
	notesel font_color_B
	notesave "data\\font_color_B.txt"

	notesel back_color_R
	notesave "data\\back_color_R.txt"

	notesel back_color_G
	notesave "data\\back_color_G.txt"

	notesel back_color_B
	notesave "data\\back_color_B.txt"
	
	DeleteObject hBrush
	
	end
	